/**
 * @param {number[]} nums
 * @return {number[][]}
 */
//  原文链接：https://blog.csdn.net/youyou_LIN/article/details/83217055
// 之后再看一看 自己再写一个
var threeSum = function(nums) {undefined
    var result = new Array();
    var len = nums.length;
    var flag = 0;
    var hash = {};
    nums.sort((a, b) => {undefined
        return a-b;
    });
    if(nums[0] > 0 || nums[len - 1] < 0) return result;
    for(var i = 0; i < len; i++){undefined
        if(nums[i] === nums[i-1]) continue;
        flag = 0 - nums[i];
        var start = i + 1, end = len - 1;
        while(start < end){undefined
            var middle = new Array();
            if(nums[start] + nums[end] < flag){undefined
                start ++;
            } else if(nums[start] + nums[end] > flag){undefined
                end--;
            } else {undefined
                middle.push(nums[i]);
                middle.push(nums[start]);
                middle.push(nums[end]);
                if(!hash[middle]){undefined
                    hash[middle] = true;
                    result.push(middle);
                }
                start += 1;
                end -= 1;
                while(start < end && nums[start] === nums[start - 1]){undefined
                    start += 1;
                }
                while(start < end && nums[end] === nums[end + 1]){undefined
                    end -= 1;
                }
            }
        }
    }
    return result;
};